package com.shiyi.design.builder;

/**
 * @author wangzhanshuai
 * @date 2021/1/27 5:46 下午
 * @since 1.0
 */
public class Person {

    private Long id;

    private String name;

    private Integer age;

    private Integer weight;

    private Integer score;

    private Location location;

    private Person() {
    }

    public static class PersonBuilder {
        private Person person = new Person();

        public PersonBuilder buildBasic(Long id, String name, Integer age) {
            this.person.id = id;
            this.person.name = name;
            this.person.age = age;
            return this;
        }

        public PersonBuilder builderWeight(Integer weight) {
            this.person.weight = weight;
            return this;
        }

        public PersonBuilder builderScore(Integer score) {
            this.person.score = score;
            return this;
        }

        public PersonBuilder builderLocation(String country, String province, String city, String street) {
            Location location = new Location();
            location.setCountry(country);
            location.setProvince(province);
            location.setCity(city);
            location.setStreet(street);
            this.person.location = location;
            return this;
        }

        public Person builder() {
            return this.person;
        }
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", weight=" + weight +
                ", score=" + score +
                ", location=" + location +
                '}';
    }
}
